﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using ProcessControl;
using System.Data;
using MyLib;

namespace ItemReim
{
    public partial class NewRequest : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            //添加提交事件
            ((ButtonList)ButtonList1).BeforeSubmit += new System.ComponentModel.CancelEventHandler(NewRequest_BeforeSubmit);
            fld_REPORTTYPE.PreRender += new EventHandler(fld_REPORTTYPE_PreRender);
        }

        void fld_REPORTTYPE_PreRender(object sender, EventArgs e)
        {
            DropDownList ddl = new DropDownList();
            TextBox tb = new TextBox();

            foreach (RepeaterItem re in fld_detail_PROC_ITEMREIM_DETAIL.Items)
            {

                ddl = re.FindControl("fld_TYPE") as DropDownList;
                ddl.Items.Clear();
                if (fld_REPORTTYPE.Text.ToString().Trim() == "租车租房劳务类")
                {
                    ddl.Items.Add(new ListItem("——请选择——", ""));
                    ddl.Items.Add(new ListItem("车辆——租赁费", "车辆——租赁费"));
                    ddl.Items.Add(new ListItem("房屋——租赁费", "房屋——租赁费"));
                    ddl.Items.Add(new ListItem("劳务费", "劳务费"));
                }

                if (fld_REPORTTYPE.Text.ToString().Trim() == "其它类")
                {
                    ddl.Items.Add(new ListItem("——请选择——", ""));
                    ddl.Items.Add(new ListItem("办公-办公用品", "办公-办公用品"));
                    ddl.Items.Add(new ListItem("办公-其他用品", "办公-其他用品"));
                    ddl.Items.Add(new ListItem("会议费", "会议费"));
                    ddl.Items.Add(new ListItem("差旅费-交通住宿", "差旅费-交通住宿"));
                    ddl.Items.Add(new ListItem("业务招待-招待费", "业务招待-招待费"));
                    ddl.Items.Add(new ListItem("业务招待-礼品", "业务招待-礼品"));
                    ddl.Items.Add(new ListItem("电话费", "电话费"));
                    ddl.Items.Add(new ListItem("邮寄费", "邮寄费"));
                    ddl.Items.Add(new ListItem("车辆-燃料费", "车辆-燃料费"));
                    ddl.Items.Add(new ListItem("车辆-过路停车费", "车辆-过路停车费"));
                    ddl.Items.Add(new ListItem("车辆-养路费", "车辆-养路费"));
                    ddl.Items.Add(new ListItem("车辆-修理费", "车辆-修理费"));
                    ddl.Items.Add(new ListItem("车辆-保险费", "车辆-保险费"));
                    ddl.Items.Add(new ListItem("车辆-其他", "车辆-其他"));
                    ddl.Items.Add(new ListItem("物资消耗", "物资消耗"));
                    ddl.Items.Add(new ListItem("低值易耗品", "低值易耗品"));
                    ddl.Items.Add(new ListItem("车辆费_停车过路费", "车辆费_停车过路费"));
                    ddl.Items.Add(new ListItem("车辆费_其他车辆费用", "车辆费_其他车辆费用"));
                    ddl.Items.Add(new ListItem("水电物业费_暖气费", "水电物业费_暖气费"));
                    ddl.Items.Add(new ListItem("水电物业费_绿化费", "水电物业费_绿化费"));
                    ddl.Items.Add(new ListItem("水电物业费_消防费", "水电物业费_消防费"));
                    ddl.Items.Add(new ListItem("物料消耗", "物料消耗"));
                    ddl.Items.Add(new ListItem("修理费", "修理费"));
                    ddl.Items.Add(new ListItem("运输费", "运输费"));
                    ddl.Items.Add(new ListItem("装卸费", "装卸费"));
                    ddl.Items.Add(new ListItem("仓储费", "仓储费"));
                    ddl.Items.Add(new ListItem("业务招待费", "业务招待费"));
                    ddl.Items.Add(new ListItem("网络费", "网络费"));
                    ddl.Items.Add(new ListItem("资料费", "资料费"));
                    ddl.Items.Add(new ListItem("咨询费服务费", "咨询费服务费"));
                    ddl.Items.Add(new ListItem("水费", "水费"));
                    ddl.Items.Add(new ListItem("电费", "电费"));
                    ddl.Items.Add(new ListItem("检测费", "检测费"));
                    ddl.Items.Add(new ListItem("出口通关费", "出口通关费"));
                    ddl.Items.Add(new ListItem("维修费", "维修费"));
                    ddl.Items.Add(new ListItem("劳保费", "劳保费"));
                    ddl.Items.Add(new ListItem("培训费", "培训费"));
                    ddl.Items.Add(new ListItem("暖气费", "暖气费"));
                    ddl.Items.Add(new ListItem("装卸费", "装卸费"));
                    ddl.Items.Add(new ListItem("运输费", "运输费"));
                    ddl.Items.Add(new ListItem("仓储费", "仓储费"));
                    ddl.Items.Add(new ListItem("保险费", "保险费"));
                    ddl.Items.Add(new ListItem("招标费", "招标费"));
                    ddl.Items.Add(new ListItem("诉讼费", "诉讼费"));
                    ddl.Items.Add(new ListItem("聘请其他机构费", "聘请其他机构费"));
                    ddl.Items.Add(new ListItem("消防费", "消防费"));
                    ddl.Items.Add(new ListItem("绿化费", "绿化费"));
                    ddl.Items.Add(new ListItem("广告费", "广告费"));
                    ddl.Items.Add(new ListItem("水电费", "水电费"));
                    ddl.Items.Add(new ListItem("其它", "其它"));
                }
                if (!IsPostBack && !string.IsNullOrEmpty(((TextBox)re.FindControl("txtTypes")).Text))
                {
                    ddl.SelectedValue = ((TextBox)re.FindControl("txtTypes")).Text;
                }

            }
        }

        //实现
        void NewRequest_BeforeSubmit(object sender, System.ComponentModel.CancelEventArgs e)
        {

            UserInfo userInfo = Page.FindControl("UserInfo1") as UserInfo;
            string Center = ((TextBox)userInfo.FindControl("var_CenterDepartment")).Text;

            string No = "";
            switch (Center)
            {
                case "运营管理中心[10003810]":
                    No = "YY";
                    break;
                case "市场部[1005053]":
                    No = "SC";
                    break;
                case "质量安全部[1005056]":
                    No = "ZL";
                    break;
                case "国际服务部[10003819]":
                    No = "GJ";
                    break;
                case "财务部[1005051]":
                    No = "CW";
                    break;
                case "人力资源部[1005052]":
                    No = "RL";
                    break;
                case "服务中心[1005069]":
                    No = "FW";
                    break;
                case "咨询中心[1005081]":
                    No = "ZX";
                    break;
                case "技术中心[10003812]":
                    No = "JS";
                    break;
                case "工程中心[1005062]":
                    No = "GC";
                    break;
                case "软件中心[1005086]":
                    No = "RJ";
                    break;

            }
            DateTime now = DateTime.Now;
            lblITEMNUMBER.Text = No + "-" + now.ToString("yyyyMMddhh24mmssffff").Substring(0, 17);
            fld_ITEMNUMBER.Text = No + "-" + now.ToString("yyyyMMddhh24mmssffff").Substring(0, 17);
        }

        //多行添加
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            UserInfo userInfo = Page.FindControl("UserInfo1") as UserInfo;
            userInfo.AddNewRow(fld_detail_PROC_ITEMREIM_DETAIL);
        }

        //多行删除
        protected void fld_detail_PROC_ITEMREIM_DETAIL_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            UserInfo userInfo = Page.FindControl("UserInfo1") as UserInfo;
            userInfo.DeleteRow(fld_detail_PROC_ITEMREIM_DETAIL, e);
        }
    }
}